package com.example.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@EnableOpenApi
public class SwaggerConfig implements WebMvcConfigurer {
    @Bean
    public Docket docket() {

        return new Docket(DocumentationType.OAS_30)
                .apiInfo(swaggerDemoApiInfo())
                .select()
                .paths(PathSelectors.regex("/.*/error").negate())
                .paths(PathSelectors.regex("/.*/actuator/health.*").negate())
                .paths(PathSelectors.regex("/.*/actuator").negate())
                .build();

    }

    private ApiInfo swaggerDemoApiInfo(){
        return new ApiInfoBuilder()
        //文档标题
		.title("电影评荐系统API")
        //文档描述
        .description("电影评荐系统")
        //文档版本
        .version( "1.0.0")
        .build();
    }
}
